keşke sample veri verseydin.. şöyle bir örnek yapalım:
table: match
id | home | visitor | score
1 ... x ..... y ...... 2-1
2 ... t ..... x ...... 2-3
3 ... s ..... a ...... 1-1
bu table ı manipule edelim.. optimizasyon yapamıcam şimdi:
bir scores tablolsu yapalım
id | team | winorlose | scores | inside | homeoraway[0:home|1:away]
bu table biraz daha adam akıllı bi şekilde oldu
php'de yazalım kodu
$q = mysql_query("select * from match");
while($r = mysql_fetch_array($q))
{
$home = $r['home'];
$visitor = $r['visitor'];
$score = $r['score'];
$pieces = explode("-",$score);
$homescore = $pieces[0];
$awayscore = $pieces[1];
if ($homescore < $awayscore)
{
$q1=mysql_query("INSERT INTO scores (team,winorlose,scores,inside,homeoraway) values ('$home','0','$homescore','$awayscore','0')");
$q1=mysql_query("INSERT INTO scores (team,winorlose,scores,inside,homeoraway) values ('$visitor','1','$awayscore','$homescore','1')");
}
else if ($awayscore < $homescore)
{
$q1=mysql_query("INSERT INTO scores (team,winorlose,scores,inside,homeoraway) values ('$home','1','$homescore','$awayscore','0')");
$q1=mysql_query("INSERT INTO scores (team,winorlose,scores,inside,homeoraway) values ('$visitor','0','$awayscore','$homescore','1')");
}
else {
$q1=mysql_query("INSERT INTO scores (team,winorlose,scores,inside,homeoraway) values ('$home','2','$homescore','$awayscore','0')");
$q1=mysql_query("INSERT INTO scores (team,winorlose,scores,inside,homeoraway) values ('$visitor','2','$awayscore','$homescore','1')");
}
}
benzer şekilde teamlist table ı da çıkartılır.. sonra her team için maç bilançoları scores tablosundan çekilir.
bol şans.
not: burada winorlose 0 yenildi, 1 yendi, 2 beraber demek. idler integer/auto increment ve primary index neyn olayları..
0